﻿using UnityEngine;

namespace GameLogic
{
    public class  FightLogicOfflineStrategy: FightLogicStrategy
    {
        public FightLogicOfflineStrategy()
        {
            m_StrategyType = StrategyType.Offline;
        }
        public override void Update()
        {
        }

        public override int GetControlShipID()
        {
            return 1;
        }
        public override void OnLogicTime()
        {
            ShipModule.Instance.DoLogic();
            BulletModule.Instance.DoLogic();
            m_OnLogicComplete.Invoke();
        }

        public override void OnFireChanged(bool value)
        {
            var shipControl = ShipModule.Instance.GetShip(GetControlShipID());
            if (shipControl)
                shipControl.SetFire(value);
        }

        public override void OnAimPositionChanged(Vector2Int pos)
        {
            var shipControl = ShipModule.Instance.GetShip(GetControlShipID());
            if (shipControl)
                shipControl.SetAimPos(pos);
        }

        public override void OnFocusPositionChanged(Vector2Int pos)
        {
            var shipControl = ShipModule.Instance.GetShip(GetControlShipID());
            if (shipControl)
                shipControl.SetFocusPosition(pos);
        }

        public override void OnMoveDirChanged(Vector2Int dir)
        {
            var shipControl = ShipModule.Instance.GetShip(GetControlShipID());
            if (shipControl)
                shipControl.SetMove(dir);
        }
    }
}